﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using Com.Toook.ParseHtml;
using Com.Toook.ParseHtml.Entity;

public partial class NextPageArticle_DownloadOrderNumber : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void ButtonGet_Click(object sender, EventArgs e)
    {
        if (!Page.IsValid)
        {
            lblMsg.Text = "输入数据不合法。";
        }
        int start = int.Parse(txtStartNumber.Text);
        int end = int.Parse(txtEndNumber.Text);
        
        string xmlFilePath = Server.MapPath("~\\App_Data\\NextPageArticle\\" + txtXmlFileName.Text + ".xml");
        CreateContentByXml createContent = new CreateContentByXml(xmlFilePath);
        DetailRoadMap roadMap = createContent.GetDetailRoadMap(txtDetailId.Text);
        GetContentNextPage html = new GetContentNextPage(roadMap);

        string url;      
        bool isOK = true;
        bool isSuccess;
        lblMsg.Text = "";
        for (int i = start; i <= end; i++)
        {           
            url = txtUrlRule.Text.Replace(txtReplace.Text.Trim(), i.ToString());//用顺序数字替换urlRule,生成url
            
            isSuccess = html.GetContentOrder(url);
            if (!isSuccess)
            {
                lblMsg.Text += i.ToString() + ", ";
                isOK = false;
            }
        }

        lblMsg.Text += isOK ? "成功" : "失败";       
    }
}
